CC =avr-gcc
CFLAGS = -g -Os -Wall -mcall-prologues -mmcu=atmega48a
OBJ2HEX =avr-objcopy
TARGET =main
ADFLAGS = -p m48 -c FT232 -P /dev/tty.usbserial-A8006Asd


.PHONY:  prog erase


prog : $(TARGET).hex $(TARGET).eeprom
	avrdude $(ADFLAGS) -V -U flash:w:$(TARGET).hex:i
#	avrdude $(ADFLAGS) -U eeprom:w:$(TARGET).eeprom:i

%.obj : %.o
	$(CC) $(CFLAGS) $< -o $@

%.hex : %.obj
	$(OBJ2HEX) -R .eeprom -O ihex $< $@

%.eeprom : %.obj
	$(OBJ2HEX) -j .eeprop -O ihex $< $@

erase :
	avrdude $(ADFLAGS) -E noreset -e
clean :
	rm -f *.hex *.obj *.o
